
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
    <title>BootstrapValidator demo</title>

    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="../lib/bootstrapvalidator/dist/css/bootstrapValidator.min.css">

    
</head>
<body>
    <div class="container">
        <div class="row">
            <!-- form: -->
            <section>
                <div class="page-header">
                    <h1>Sign up</h1>
                </div>

                <div class="col-lg-8 col-lg-offset-2">
                    <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
                        <div class="form-group">
                            <label class="col-lg-3 control-label">Username</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control" name="username" autocomplete="off" />
                            </div>
                        </div>

                       
                      

                        

                        <div class="form-group">
                            <div class="col-lg-9 col-lg-offset-3">
                                <button type="submit" class="btn btn-primary">Submit</button>
                            </div>
                        </div>
                    </form>
                </div>
            </section>
            <!-- :form -->
        </div>
    </div>

<script src="../lib/jquery/jquery-2.1.1.js"></script>
<script src="../lib/bootstrap/js/bootstrap.min.js"></script>
<script src="../lib/bootstrapvalidator/dist/js/bootstrapValidator.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $('#defaultForm').bootstrapValidator({
        message: 'This value is not valid',
//        live: 'disabled',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {

                

                message: 'The username is not valid',
                // threshold :  6,
                validators: {
                  notEmpty: {
                            message: '担保数量不能为空！'
                        },

                        regexp: {/* 包含正则表达式，和提示 */
                            regexp: /^[1-9]\d*$/,
                            message: '请输入正确的数量！'


                        },
                        
                        callback: {
                            message: '最低交易数量为10000！',
                            callback:function(value, validator,$field){
                                var buyCount = 10000;
                                if(value * 1 < buyCount){
                                    

                                    return false;
                                }
                                return true;

                            }
                        },
                      
                    remote: {

                        url: 'remote.php',
                        message: 'The username is not available',
                        // delay: 2000,//每输入一个字符，就发ajax请求，服务器压力还是太大，设置2秒发送一次ajax（默认输入一个字符，提交一次，服务器压力太大）
                        delay :  3000,
                          type: 'POST'//请求方式
                    }
                    
                }
            }
           
           
            
        }
    });
});
</script>
</body>
</html>